<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>解码给定的 URL 编码的字符串</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.curl-unescape" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">curl_unescape</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.5.0, PHP 7)</p><p class="refpurpose"><span class="refname">curl_unescape</span> &mdash; <span class="dc-title">解码给定的 URL 编码的字符串</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.curl-unescape-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>curl_unescape</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$ch</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$str</code></span>
   ) : <span class="type">string</span></div>

  <p class="para rdfs-comment">
   该函数解码给定的 URL 编码的字符串。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.curl-unescape-parameters">
  <h3 class="title">参数</h3>
  <dl>

   <dt>
<code class="parameter">ch</code>
</dt>
<dd>
<p class="para">由 <span class="function"><a href="curl_init.html" class="function">curl_init()</a></span> 返回的 cURL 句柄。</p></dd>

   
    <dt>
<code class="parameter">str</code></dt>

    <dd>

     <p class="para">
      需要解码的 URL 编码字符串
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.curl-unescape-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回解码后的字符串 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.curl-unescape-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5258">
    <p><strong>Example #1 <span class="function"><a href="curl_escape.html" class="function">curl_escape()</a></span> 示例</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;创建一个&nbsp;curl&nbsp;句柄<br /></span><span style="color: #0000BB">$ch&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">curl_init</span><span style="color: #007700">(</span><span style="color: #DD0000">'http://example.com/redirect.php'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;发送&nbsp;HTTP&nbsp;请求并且遵循重定向<br /></span><span style="color: #0000BB">curl_setopt</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">CURLOPT_FOLLOWLOCATION</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">curl_exec</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;获取最后的有效&nbsp;URL<br /></span><span style="color: #0000BB">$effective_url&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">curl_getinfo</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">CURLINFO_EFFECTIVE_URL</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;结果：&nbsp;"http://example.com/show_location.php?loc=M%C3%BCnchen"<br /><br />//&nbsp;解码这个&nbsp;URL<br /></span><span style="color: #0000BB">$effective_url_decoded&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">curl_unescape</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$effective_url</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;"http://example.com/show_location.php?loc=München"<br /><br />//&nbsp;关闭句柄<br /></span><span style="color: #0000BB">curl_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.curl-unescape-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    <span class="function"><strong>curl_unescape()</strong></span> 不会将加号 (+) 解码成空格。而 <span class="function"><a href="urldecode.html" class="function">urldecode()</a></span> 会。
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.curl-unescape-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="curl_escape.html" class="function" rel="rdfs-seeAlso">curl_escape()</a> - 使用 URL 编码给定的字符串</span></li>
    <li class="member"><span class="function"><a href="urlencode.html" class="function" rel="rdfs-seeAlso">urlencode()</a> - 编码 URL 字符串</span></li>
    <li class="member"><span class="function"><a href="urldecode.html" class="function" rel="rdfs-seeAlso">urldecode()</a> - 解码已编码的 URL 字符串</span></li>
    <li class="member"><span class="function"><a href="rawurlencode.html" class="function" rel="rdfs-seeAlso">rawurlencode()</a> - 按照 RFC 3986 对 URL 进行编码</span></li>
    <li class="member"><span class="function"><a href="rawurldecode.html" class="function" rel="rdfs-seeAlso">rawurldecode()</a> - 对已编码的 URL 字符串进行解码</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>